.. _Build NeurEco Parametric Frequency Sweep model with the Python API:

Build NeurEco Parametric Frequency Sweep model with the Python API
===================================================================

To build a NeurEco **Parametric Frequency Sweep** model in Python API, import **NeurEcoFrequential** library:

.. code-block:: python

  from NeurEco import NeurEcoFrequential as Frequential 
	
Initialize a NeurEco object to handle the **Parametric Frequency Sweep** problem:

.. code-block:: python

  model = Frequential.PFS()
	
Call method **build** with the parameters set for the problem under consideration:

.. code-block:: python

  model.build(input_data, output_data,
                   validation_input_data=None,
                   validation_output_data=None,
                   valid_percentage=None,
                   test_input_data=None,
                   test_output_data=None,
                   write_model_to="",
                   checkpoint_address="",
                   compressed_space_size=5,
                   min_number_of_enrichments=100,
                   max_number_of_enrichments=200,
                   unsuccessful_enrichments_threshold=4,
                   enrichment_rate=0.2,
                   resume=False
                   )

:input_data: NumPy array, dtype=float64, required: NumPy array of the training input data. The shape is :math:`(m,\ n)`, where :math:`m` is the number of samples, and :math:`n` is the number of input variables
:output_data: NumPy array, dtype=complex128, required: NumPy array of training target data. The shape is :math:`(m,\ n)` where :math:`m` is the number of samples, and :math:`n` is the number of output variables.
:validation_input_data: NumPy array, dtype=float64, optional: Numpy array of validation input data. The shape is :math:`(m,\ n)` where :math:`m` is the number of samples, and :math:`n` is the number of input variables.
:validation_output_data: NumPy array, dtype=complexe, optional: Numpy array of validation target data. The shape is :math:`(m,\ n)` where :math:`m` is the number of samples, and :math:`n` is the number of output variables.
:test_input_data: NumPy array, dtype=float64, optional: Numpy array of test input data. The shape is :math:`(m,\ n)` where :math:`m` is the number of samples, and :math:`n` is the number of input variables.
:test_output_data: NumPy array, dtype=complexe, optional: Numpy array of test target data. The shape is :math:`(m,\ n)` where :math:`m` is the number of samples, and :math:`n` is the number of output variables.
:write_model_to: string, optional, default is None: path on the disk where to save the model
:valid_percentage: float, optional, default is :math:`33.33`: Percentage of the data that NeurEco will select to use as validation data. The minimum accepted value is 1 (1%). The maximum accepted value is  :math:`50` (50%). Ignored unless validation data is None.
:checkpoint_address: string, optional, default is "": the path where the checkpoint model will be saved. The checkpoint model is used for resuming the build of a model, or for choosing an intermediate network with less topological optimization steps.
:reduced_space_size: int: the dimension of the reduced space (outputs) used to train the model
:min_number_of_enrichments: int: the minimum number of enrichments
:max_number_of_enrichments: int: the maximum number of enrichments
:unsuccessful_enrichments_threshold: int: maximum number of consecutive unsuccessful enrichment steps (no imrovement of validation error) before stopping the training process
:enrichment_rate: float: tunes the quantity of new parameters added at every enrichment step (has to be included between 0 and 1)
:resume: Bool, default=False: Used to resume an interrupted build
:return: build_status: int: 0 if build is successful, other if otherwise

For more information on the data format, see :std:ref:`Data preparation for NeurEco Parametric Frequency Sweep python`.

.. _Data normalization for Parametric Frequency Sweep Python:

Data normalization for Parametric Frequency Sweep
-----------------------------------------------------

.. include:: ../CommonPartsPFS/NormalizationPFS.rst

